<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <title>项目评审汇总(普通用户)2021_1</title>
    <link rel="stylesheet" href="/static/plugin/layui/css/layui.css" media="all" />
    <link rel="stylesheet" href="/static/plugin/zTree_v3/css/zTreeStyle/zTreeStyle.css">
    <script src="/static/plugin/zTree_v3/js/jquery-1.4.4.min.js"></script>
    <script type="text/javascript" src="/static/plugin/layui/layui.js"></script>
    <script src="/static/plugin/ztree/js/jquery.ztree.core.js"></script>
    <script src="/static/plugin/ztree/js/jquery.ztree.excheck.js"></script>
    <script src="/static/plugin/ztree/js/jquery.ztree.exedit.js"></script>
    <script type="text/javascript" src="/static/js/base.js"></script>
    <script type="text/javascript" src="/static/js/formSelects.js"></script>
    <script type="text/javascript" src="/static/js/highcharts.js"></script>
    <style>
        .layui-table th{
            font-weight: bold;
            font-size: 16px;
        }
        .layui-table td{
            font-weight: bold;
            font-size: 16px;
        }
    </style>
<body>
<div class="layui-fluid">
    <div class="layui-row">
        <div class="layui-col-md7">
            &nbsp;
           <!-- <fieldset id="menu_func_div" class="layui-elem-field">
                <legend>项目列表</legend>

            </fieldset>-->

            <div class="layui-row" style="margin-bottom: 18px">
                <div class="layui-form">
                    <div class="layui-input-inline">

                        <div class="layui-input-inline" style="width: 150px">
                            <input class="layui-input" id="keyword01" placeholder="请输入项目名称" style="width: 150px">
                        </div>
                        <button class="layui-btn layui-btn-normal" data-type="reload"><i class="layui-icon layui-icon-search"></i>检索</button>
                        <!--<button class="layui-btn" id="appraise"><i class="layui-icon layui-icon-duigou"></i>结果调整</button>
                        <button class="layui-btn" id="export"><i class="layui-icon layui-icon-xiazai"></i>结果导出</button>
                        <button class="layui-btn" id="appraise_detail"><i class="layui-icon layui-icon-biaoge"></i>评审撤回</button>-->
                        <span style="display: none" id="aminId">
                            <button class="layui-btn" id="appraise"><i class="layui-icon layui-icon-duigou"></i>结果调整</button>
                            <button class="layui-btn" id="export"><i class="layui-icon layui-icon-xiazai"></i>结果导出</button>
                            <button class="layui-btn" id="appraise_detail"><i class="layui-icon layui-icon-biaoge"></i>评审撤回</button>
                            <button class="layui-btn" id="appraise_next"><i class="layui-icon layui-icon-biaoge"></i>二次评审</button>
                        </span>
                    </div>
                </div>
            </div>
            <table class="layui-hide" id="tableList" lay-filter="tableList"></table>
        </div>
        <!--style="border-left-style: solid;height: 400px"-->
        <div class="layui-col-md5" >
            <!--<fieldset class="layui-elem-field">
                <legend>评审结果</legend>

            </fieldset>-->
            <div class="layui-row layui-col-space10">
                <div class="layui-col-md12">
                    <div id="container" style="min-width:400px;height:400px"></div>
                </div>
            </div>
        </div>
    </div>
</div>

<!--评审详情框-->
<div id="detailDiv" style="display:none">
    <table class="layui-hide" id="detailList" lay-filter="detailList"></table>
</div>

<!--评审框-->
<div id="appraiseDiv" style="display:none">
    <form class="layui-form" id="appraiseFormID" style="margin-top:20px">
        <div class="layui-form-item">
            <label class="layui-form-label">项目名称</label>
            <input type="hidden" id="projectId">
            <div class="layui-input-inline" style = "width:300px;">
                <input type="text" value=""  id="pname" name="pname" readonly autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
                判定等级<span style="color: red">*</span>
            </label>
            <div class="layui-input-inline" style = "width:300px;">
                <select lay-verify="cid" id="cid" name="cid" lay-search="">
                    <option value="1">一等奖</option>
                    <option  value="4">二等奖</option>
                    <option  value="7">三等奖</option>
                    <option  value="0">其他</option>
                    <!--<option>二等奖B</option>
                    <option>二等奖C</option>-->
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">评审人</label>
            <div class="layui-input-inline" style = "width:300px;">
                <input type="text"  id="people" value="管理员" name="people" readonly autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item" style="margin-left: 70px">
            <div class="layui-input-block">
                <button class="layui-btn layui-btn-blue" lay-submit lay-filter="appraiseform" id="appraiseSubform">提交</button>
                <button class="layui-btn layui-btn-primary" onclick="CloseWin()"  id="closeBtn">取消</button>
            </div>
        </div>
    </form>
</div>

<div id="exportDiv" style="display:none">
    <form class="layui-form" id="exportFormID" style="margin-top:20px">

        <div class="layui-form-item">
            <label class="layui-form-label">导出范围</label>
            <div class="layui-input-block">
                <input type="radio" name="sex1" value="0" title="全部导出">
                <input type="radio" name="sex1" value="1" title="选中导出" checked>
            </div>
        </div>


        <div class="layui-form-item">
            <label class="layui-form-label">文件名称</label>
            <div class="layui-input-inline" style = "width:300px;">
                <input type="text" value="" id="exportName"  name="exportName" readonly autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">导出格式</label>
            <div class="layui-input-block">
                <input type="radio" name="sex2" value="男" title="Excel" checked>
            </div>
        </div>
    </form>
</div>
<input hidden id="pid" name="pid">
<button id="chartShow" onclick="chartShow1()" hidden></button>

<script th:inline="javascript">
    function chartShow1(){
        $.ajax({
            url: "/appraise/chart2021",
            type: "post",
            data: {pid:$.trim($("#pid").val())},
            dataType:'json', //JSON类型
            success: function(result){
                Highcharts.chart('container', {
                    chart: {
                        type: 'column'
                    },
                    title: {
                        text: result.type
                    },
                    subtitle: {
                        text: result.subtitle
                    },
                    xAxis: {
                        type: 'category'
                    },
                    yAxis: {
                        title: {
                            text: '投票数(人)'
                        }
                    },
                    legend: {
                        enabled: false
                    },
                    plotOptions: {
                        series: {
                            borderWidth: 0,
                            dataLabels: {
                                enabled: true,
                                format: '{point.y}'
                            }
                        }
                    },
                    tooltip: {
                        headerFormat: '<span style="font-size:14px">{point.key}</span>：',
                        pointFormat: '<span style="color:{point.color}">评奖人数</span>  <b>{point.y}</b><br/>'
                    },
                    series: [{
                        name: '',
                        colorByPoint: true,
                        data: [{
                            name: '同意',
                            y: result.agree,
                        }, {
                            name: '不同意',
                            y: result.notAgree,
                        }]
                    }],
                });
            }
        });
    }
</script>
<script th:inline="javascript">
    let idea = [[${idea}]];
    let userId = [[${userId}]]
    var dropBox = document.getElementById("aminId");
    setTimeout(function () {
        if (userId == 35) {
            dropBox.style.display = "inline";
        }
    },1000)

    var treeObj;
    var treeObj2;

    function createTime(v){
        var date = new Date(v);
        var y = date.getFullYear();
        var m = date.getMonth()+1;
        m = m<10?'0'+m:m;
        var d = date.getDate();
        d = d<10?("0"+d):d;
        var h = date.getHours();
        h = h<10?("0"+h):h;
        var M = date.getMinutes();
        M = M<10?("0"+M):M;
        var str = y+"-"+m+"-"+d+" "+h+":"+M;
        return str;
    }

    $(document).ready(function () {
        var time = new Date();
        var day = ("0" + time.getDate()).slice(-2);
        var month = ("0" + (time.getMonth() + 1)).slice(-2);
        var today = time.getFullYear() + "-" + (month);
        $('#dateTime').val(today);
    })

    layui.use(['table','layer','upload','form','laydate'], function(){
        var table = layui.table;
        var form=layui.form;
        var laydate = layui.laydate;
        laydate.render({
            elem: '#date1',
            value:new Date()
        });
        laydate.render({
            elem: '#date2'
        });

        laydate.render({
            elem: '#date3',
            type: 'month',
            value: new Date(),
            done:function(value, date, endDate) {
                $('#dateTime').val(value);
            }
        });

        var $ = layui.jquery, active = {
            reload:function () {
                table.reload('contentTable',{
                    method:'get'
                    ,where:{
                        'projectName':$('#keyword01').val()
                    }
                    /*,page: {
                        curr: 1//重新从第 1 页开始
                    }*/
                });
            }
        }

        table.render({
            elem: '#tableList'
            ,id:'contentTable'
            ,url: '/projectSummary/queryPage?idea='+idea
            ,height: 420
            ,where:{
                'projectName':""
            }
            , cols: [

                [
                    {field:'id',type:'checkbox', width: 40}
                    , {field: 'pnumber', title: '序号', width: 65}
                    , {field: 'pname', title: '项目名称', minWidth:160}
                    , {field: 'evaluationOpinion', title: '同意票', width: 80}
                    , {field: 'evaluationOpinionNext', title: '二次', width: 65}
                    , {field: 'type', title: '类型', width: 210}
                    , {field: 'idea', title: '专业组意见', width: 110}
                    /*, {field: 'scoring', title: '打分', width: 80}*/
                    /*, {field: 'awardsresult', title: '评定等级', width: 120,templet:function (r) {
                        if (r.awardsresult == 1) {
                            return '一等奖'
                        }else if (r.awardsresult == 4) {
                            return '二等奖'
                        }else if (r.awardsresult == 7) {
                            return '三等奖'
                        }else if (r.awardsresult == 0) {
                            return '其他'
                        }else {
                            return ''
                        }
                    }}*/
                    /*, {field: 'primaryAwardsResult', title: '原等级', width: 120,templet:function (r) {
                        if (r.primaryAwardsResult == 1) {
                            return '一等奖A'
                        }else if (r.primaryAwardsResult == 2) {
                            return '一等奖B'
                        }else if (r.primaryAwardsResult == 3) {
                            return '一等奖C'
                        }else if (r.primaryAwardsResult == 4) {
                            return '二等奖A'
                        }else if (r.primaryAwardsResult == 5) {
                            return '二等奖B'
                        }else if (r.primaryAwardsResult == 6) {
                            return '二等奖C'
                        }else if (r.primaryAwardsResult == 7) {
                            return '三等奖A'
                        }else if (r.primaryAwardsResult == 8) {
                            return '三等奖B'
                        }else if (r.primaryAwardsResult == 9) {
                            return '三等奖C'
                        } else if (r.primaryAwardsResult == 0) {
                            return '其他'
                        }else {
                            return ''
                        }
                    }}*/
                ]
            ]
            /*,page: true
            ,totalRow: true*/
            ,done : function(res, curr, count){
                $('th').css({
                    'background-color': '#3388CB', 'color': '#fff','font-weight':'bold',
                })
            }
        });

        $('.demoTable .layui-btn').on('click', function(){
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });

        $('.layui-col-md12 .layui-btn').on('click', function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
        $('.select .layui-btn').on('click', function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
        $('.layui-btn').on('click', function(){
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });

        table.on('row(tableList)',function (obj) {
            $(".layui-table-body tr ").attr({"style":"background:#FFFFFF"});//其他tr恢复原样
            $(obj.tr.selector).attr({"style":"background:#99ff99"});//改变当前tr颜色
            $("#pid").val(obj.data.id);
            $("#chartShow").click();
        });


        //监听工具条
        table.on('tool(tableList)', function (obj) {
            var data = obj.data;
            if (obj.event === 'detail') {
                detail('编辑角色', 'updateDept?id=' + data.deptId, 600, 350);
            } else if (obj.event === 'del') {
                layer.confirm('确定删除部门？[<label style="color: #00AA91;">' + data.deptName + '</label>]?', {
                    btn: ['确定','取消'] //按钮
                }, function(index){
                    del(data.deptId)
                })

            } else if (obj.event === 'edit') {
                update('编辑部门', 'updateDept?id=' + data.deptId, 700, 450);
            }
        });

        // 二次撤回
        $('#appraise_next').click(function () {
            var rowData = table.checkStatus('contentTable');
            var data = rowData.data;
            if(data.length == 0){
                layer.alert("请勾选要操作的项！",{icon :5})
                return;
            }

            // 将项目id拼接成数组
            let projectIds = [];
            for (const item of rowData.data) {
                projectIds.push(item.id);
            }

            layer.confirm("该操作不可撤回，是否继续？", {
                btn: ["确定","取消"] //按钮
            }, function(){
                $.ajax({
                    type:'get',
                    data:{projectIds:projectIds.toString()},
                    url:'/projectExpert/approvalNext',
                    success:function (result) {
                        if (result) {
                            layer.msg('操作成功',{icon:6})
                            setTimeout(function(){
                                table.reload('contentTable',{
                                    method:'get'
                                });
                            },1000);
                        }
                    }
                });
            });
        });

        //查看评审详情
        $("#appraise_detail").click(function(){
            var rowData = table.checkStatus('contentTable');
            var data = rowData.data;
            if(data.length == 0){
                layer.alert("请勾选要操作的项！",{icon :5})
            } else {
                layer.open({
                    type: 1,				//Page层类型
                    area: ['750px', '520px'] 	//宽  高
                    , title: '评审撤回'
                    ,btn:['取消']
                    , shade: 0.6 			//遮罩透明度
                    , maxmin: true 			//允许全屏最小化
                    , anim: 1 				//0-6的动画形式，-1不开启
                    , content: $('#detailDiv')
                    , success: function () {

                        table.render({
                            elem: '#detailList'
                            ,id:'contentTable2'
                            ,url: '/projectExpert/queryExpertList'
                            ,where:{
                                projectId: data[0].id
                            }
                            ,cols: [
                                [
                                     {field:'uid', title:'序号', width: 50, type:'numbers',align:'center'}
                                    ,{field: 'realName', title: '专家姓名', width: 150}
                                    ,{field: 'state1', title: '评定意见', align:'center',width: 300,templet:function (d) {
                                        let id = d.id;
                                        let evaluationOpinion = d.evaluationOpinion;
                                        let actions = [];
                                        if (evaluationOpinion == 0) {
                                            actions.push('<input type="radio" name="gender'+id+'" value="0" checked/>同意')
                                        }else {
                                            actions.push('<input type="radio" name="gender'+id+'" value="0"/>同意')
                                        }
                                        actions.push(' ')
                                        actions.push(' ')
                                        actions.push(' ')
                                        if (evaluationOpinion == 1) {
                                            actions.push('<input type="radio" name="gender'+id+'" value="1" checked/>不同意(降为二等奖)')
                                        }else {
                                            actions.push('<input type="radio" name="gender'+id+'" value="1"/>不同意(降为二等奖)')
                                        }
                                        return actions.join("&nbsp;")
                                    }}
                                    /*,{field: 'state2', title: '打分', align:'center',width: 100,templet:function (d) {
                                        let id = d.id;
                                        let scoring = d.scoring;
                                        return '<input type="number" style="width: 100%" id = "numberId'+id+'" value="'+scoring+'">'
                                    }}*/
                                    /*,{field: 'level', title: '评审等级', width: 150,templet:function (r) {
                                        if (r.level == 1) {
                                            return '一等奖'
                                        }else if (r.level == 4) {
                                            return '二等奖'
                                        }else if (r.level == 7) {
                                            return '三等奖'
                                        }else if (r.level == 0) {
                                            return '暂未评定等级'
                                        }else {
                                            return '';
                                        }
                                    }}*/
                                    ,{field: 'remark', title: '操作', width: 100,templet:function (r) {
                                        return '<a class="layui-btn layui-btn-xs  layui-btn-normal" onclick="expertRecall('+r.id+')">撤回</a>'
                                    }}
                                ]
                            ]
                        });
                    }
                });
            }
        });

        //撤回
        window.expertRecall = function(id) {
            layer.confirm("该操作不可撤回，是否继续？", {
                btn: ["确定","取消"] //按钮
            }, function(){
                $.ajax({
                    type:'get',
                    data:{id:id},
                    url:'/projectExpert/updateExpertRecall2021',
                    success:function (result) {
                        if (result) {
                            layer.msg('操作成功',{icon:6})
                            setTimeout(function(){
                                table.reload('contentTable2',{
                                    method:'get'
                                });

                            },1000);
                        }
                    }
                });
            });
        }

        //导出
        $('#export').click(function () {
            let date = new Date();
            let year = date.getFullYear();
            let month = date.getMonth()+1;
            let day = date.getDate();
            let hour = date.getHours();
            let minute = date.getMinutes();
            let second = date.getSeconds();
            $('#exportName').val('download_'+year+''+month+''+day+''+hour+''+minute+''+second);
            layer.open({
                type: 1 ,				//Page层类型
                area: ['540px', '420px'] 	//宽  高
                ,title: '导出数据'
                ,shade: 0.6 			//遮罩透明度
                ,maxmin: true 			//允许全屏最小化
                ,anim: 1 				//0-6的动画形式，-1不开启
                ,content: $('#exportDiv'),
                btn: [ '导出', '关闭'],
                btn1:function (index) {

                    let rowData = table.checkStatus('contentTable');
                    let data = rowData.data;

                    let exportName = $('#exportName').val();

                    let sex1 = $('input[name="sex1"]:checked').val();
                    if(sex1 == 0) {
                        //全部导出
                        window.location.href = "/project/project/exportExcel?exportName="+exportName+"&type=1&projectId=0"
                    }else if(sex1 == 1){
                        //选中导出
                        if (data.length === 0) {
                            layer.msg('请选择要导出的项目',{icon:5})
                            return;
                        }

                        let ids = [];
                        for (let i = 0; i < data.length; i++) {
                            ids.push(data[i].id);
                        }
                        window.location.href = "/project/exportExcel?exportName="+exportName+"&projectId="+ids+"&type=1"
                    }

                },
                btn2:function (index) {

                }
            });


        });


        //结果调整
        $("#appraise").click(function(){
            let rowData = table.checkStatus('contentTable');
            let data = rowData.data;
            if(data.length === 0){
                layer.alert("请勾选要操作的项！",{icon :5})
            } else {
                layer.open({
                    type: 1 ,				//Page层类型
                    area: ['540px', '420px'] 	//宽  高
                    ,title: '结果调整'
                    ,shade: 0.6 			//遮罩透明度
                    ,maxmin: true 			//允许全屏最小化
                    ,anim: 1 				//0-6的动画形式，-1不开启
                    ,content: $('#appraiseDiv')
                    ,success: function(){
                        $("input[name='pname']").val(data[0].pname);
                        $("#projectId").val(data[0].id);
                        $("input[name='people']").val("管理员");
                        $('#cid').val(data[0].awardsresult);
                        form.render();
                    }
                });
            }
        });


        //关闭页面
        window.CloseWin = function() {
            let index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
            //layer.msg(index);
            parent.layer.close(index); //再执行关闭
        }



        /**  data:{itemName:"12",startDate:'2019-09-20'},
         * 通用表单提交(AJAX方式),totalMoney:100,startDate:'2019-09-20',dueDate:'2019-09-20'
         */
        form.on('submit(appraiseform)', function () {
            $("#appraiseSubform").attr("disabled",true);
            $.ajax({
                type:'post',
                url:'/projectSummary/update',
                data:{projectId:$("#projectId").val(),awardsAdmin:$('#cid').val()},
                cache:false,
            }).done(
                function(res) {
                    if (res) {
                        layer.msg('新增成功',{icon:6})
                        setTimeout(function(){
                            location.reload();
                        },1000);
                    }
                }
            ).fail(
                function() {
                    layer.msg('新增失败',{icon:5})
                    setTimeout(function(){
                        location.reload();
                    },1000);
                }
            )
            return false;
        })

    });
</script>
</body>
</html>
